package com.ruoyi.message.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.message.model.MsgCirculation;
import com.ruoyi.message.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController extends BaseController {
    @Autowired
    MessageService service;

    @GetMapping("/list")
    public TableDataInfo list(MsgCirculation msg){
        startPage();
        msg.setUserId(SecurityUtils.getUserId());
        List<MsgCirculation> r = service.selectByUserId(msg);
        return getDataTable(r);
    }
    @GetMapping("/confirm")
    public AjaxResult confirm(Long id){
        service.confirm(id);
        return success();
    }

    @GetMapping("/sum")
    public AjaxResult sum(){
        return success(service.selectSum());
    }
}
